CREATE VIEW DBO.TRB_IPTU_DENTRO_IMPAR_UNICA AS
SELECT DISTINCT IPTU.TLA_COD
	FROM TRB_IMOVEL_VI  IMOV  
	JOIN TRB_IPTU       IPTU ON IMOV.IMV_COD = IPTU.IMV_COD  
	JOIN TRB_LANCAMENTO LANC ON IPTU.TLA_COD = LANC.TLA_COD  
	WHERE   
		NOT( NOME_PROPRIETARIO = 'IGN' AND OLO_TIPO = 'T' AND IMV_TIPO_END_ENTREGA = 'I' )  
		AND (MUN_NOME = 'LAURO DE FREITAS' OR IMV_TIPO_END_ENTREGA = 'I')    
		AND ( EXE_ANO = '2008' )  
		AND ( DBO.FN_METRICO_PAR(IMV_INSCRICAO) = 0 )  
		AND ( DBO.SOUNICA(IMV_INSCRICAO) = 1 )
GO

CREATE VIEW DBO.TRB_IPTU_DENTRO_IMPAR_PARCELA AS
SELECT DISTINCT IPTU.TLA_COD
	FROM TRB_IMOVEL_VI  IMOV  
	JOIN TRB_IPTU       IPTU ON IMOV.IMV_COD = IPTU.IMV_COD  
	JOIN TRB_LANCAMENTO LANC ON IPTU.TLA_COD = LANC.TLA_COD  
	WHERE   
		NOT( NOME_PROPRIETARIO = 'IGN' AND OLO_TIPO = 'T' AND IMV_TIPO_END_ENTREGA = 'I' )  
		AND (MUN_NOME = 'LAURO DE FREITAS' OR IMV_TIPO_END_ENTREGA = 'I')    
		AND ( EXE_ANO = '2008' )  
		AND ( DBO.FN_METRICO_PAR(IMV_INSCRICAO) = 0 )  
		AND ( DBO.SOUNICA(IMV_INSCRICAO) = 0 )
GO

CREATE VIEW DBO.TRB_IPTU_DENTRO_PAR_UNICA AS
SELECT DISTINCT IPTU.TLA_COD
	FROM TRB_IMOVEL_VI  IMOV  
	JOIN TRB_IPTU       IPTU ON IMOV.IMV_COD = IPTU.IMV_COD  
	JOIN TRB_LANCAMENTO LANC ON IPTU.TLA_COD = LANC.TLA_COD  
	WHERE   
		NOT( NOME_PROPRIETARIO = 'IGN' AND OLO_TIPO = 'T' AND IMV_TIPO_END_ENTREGA = 'I' )  
		AND (MUN_NOME = 'LAURO DE FREITAS' OR IMV_TIPO_END_ENTREGA = 'I')    
		AND ( EXE_ANO = '2008' )  
		AND ( DBO.FN_METRICO_PAR(IMV_INSCRICAO) = 1 )
		AND ( DBO.SOUNICA(IMV_INSCRICAO) = 1 )
GO

CREATE VIEW DBO.TRB_IPTU_DENTRO_PAR_PARCELA AS
SELECT DISTINCT IPTU.TLA_COD
	FROM TRB_IMOVEL_VI  IMOV  
	JOIN TRB_IPTU       IPTU ON IMOV.IMV_COD = IPTU.IMV_COD  
	JOIN TRB_LANCAMENTO LANC ON IPTU.TLA_COD = LANC.TLA_COD  
	WHERE   
		NOT( NOME_PROPRIETARIO = 'IGN' AND OLO_TIPO = 'T' AND IMV_TIPO_END_ENTREGA = 'I' )  
		AND (MUN_NOME = 'LAURO DE FREITAS' OR IMV_TIPO_END_ENTREGA = 'I')    
		AND ( EXE_ANO = '2008' )  
		AND ( DBO.FN_METRICO_PAR(IMV_INSCRICAO) = 1 )  
		AND ( DBO.SOUNICA(IMV_INSCRICAO) = 0 )
GO

CREATE VIEW DBO.TRB_IPTU_FORA_UNICA AS
SELECT DISTINCT IPTU.TLA_COD
	FROM TRB_IMOVEL_VI  IMOV  
	JOIN TRB_IPTU       IPTU ON IMOV.IMV_COD = IPTU.IMV_COD  
	JOIN TRB_LANCAMENTO LANC ON IPTU.TLA_COD = LANC.TLA_COD  
	WHERE   
		NOT( NOME_PROPRIETARIO = 'IGN' AND OLO_TIPO = 'T' AND IMV_TIPO_END_ENTREGA = 'I' )  
		AND (MUN_NOME <> 'LAURO DE FREITAS')
		AND ( EXE_ANO = '2008' )  
		-- AND ( DBO.FN_METRICO_PAR(IMV_INSCRICAO) = 0 )  
		AND ( DBO.SOUNICA(IMV_INSCRICAO) = 1 )
GO

CREATE VIEW DBO.TRB_IPTU_FORA_PARCELA AS
SELECT DISTINCT IPTU.TLA_COD
	FROM TRB_IMOVEL_VI  IMOV  
	JOIN TRB_IPTU       IPTU ON IMOV.IMV_COD = IPTU.IMV_COD  
	JOIN TRB_LANCAMENTO LANC ON IPTU.TLA_COD = LANC.TLA_COD  
	WHERE   
		NOT( NOME_PROPRIETARIO = 'IGN' AND OLO_TIPO = 'T' AND IMV_TIPO_END_ENTREGA = 'I' )  
		AND (MUN_NOME <> 'LAURO DE FREITAS')    
		AND ( EXE_ANO = '2008' )  
		-- AND ( DBO.FN_METRICO_PAR(IMV_INSCRICAO) = 0 )  
		AND ( DBO.SOUNICA(IMV_INSCRICAO) = 0 )
GO
